package com.enation.app.shop.front.policyInsurance.service.impl;

import com.enation.app.shop.front.policyInsurance.entity.Supplier;
import com.enation.app.shop.front.policyInsurance.service.ISupplierMapper;
import com.enation.framework.database.IDaoSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("supplierservice")
public class SupplierService implements ISupplierMapper {
    @Autowired
    private IDaoSupport daoSupport;
    @Override
    public int deleteByPrimaryKey(Long id) {
        return 0;
    }

    @Override
    public int insert(Supplier record) {
        this.daoSupport.insert("rbt_supplier",record);
        return 1;
    }

    @Override
    public int insertSelective(Supplier record) {
        return 0;
    }

    @Override
    public Supplier selectByPrimaryKey(Long id) {
        return null;
    }

    @Override
    public int updateByPrimaryKeySelective(Supplier record) {
        return 0;
    }

    @Override
    public int updateByPrimaryKey(Supplier record) {
        return 0;
    }

    @Override
    public List<Supplier> getAll() {
        String sql="select * from rbt_supplier";
        return this.daoSupport.queryForList(sql,Supplier.class);
    }

    @Override
    public List<Supplier> getByPage(int page, Integer limit, String seacher) {
        if (seacher==null){
            String sql="select * from  rbt_supplier limit ?,?";
            return this.daoSupport.queryForList(sql,Supplier.class,page,limit);
        }else {
            String sql="select * from  rbt_supplier  where supplier_name like '%"+seacher+"%' limit ?,?";
            return this.daoSupport.queryForList(sql,Supplier.class,page,limit);
        }
    }

    @Override
    public List<Supplier> getBySercher(String seacher) {
        String sql="select * from  rbt_supplier where supplier_name like '%"+seacher+"%'";
        return this.daoSupport.queryForList(sql,Supplier.class);
    }
}
